--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Commit da348c3b42d69281e7344f707d944cd9f1317891
Parents : 92c3c55
Author : Mark Qvist <mark@unsigned.io>
Date : 2023-09-19T14:46:52+02:00
Improved propagation peer list display
Changes
2 files changed, 16 insertions(+), 4 deletions(-)
Diff
diff --git a/nomadnet/ui/TextUI.py b/nomadnet/ui/TextUI.py
index 3f38744..9ecdddc 100644
--- a/nomadnet/ui/TextUI.py
+++ b/nomadnet/ui/TextUI.py
@@ -45,6 +45,8 @@ THEMES = {
("list_normal", "dark gray", "default", "default", "#bbb", "default"),
("list_untrusted", "dark red", "default", "default", "#a22", "default"),
("list_focus_untrusted", "black", "light gray", "standout", "#810", "#aaa"),
+ ("list_unresponsive", "yellow", "default", "default", "#b92", "default"),
+ ("list_focus_unresponsive", "black", "light gray", "standout", "#530", "#aaa"),
("topic_list_normal", "light gray", "default", "default", "#ddd", "default"),
("browser_controls", "light gray", "default", "default", "#bbb", "default"),
("progress_full", "black", "light gray", "standout", "#111", "#bbb"),
@@ -78,6 +80,8 @@ THEMES = {
("list_normal", "dark gray", "default", "default", "#444", "default"),
("list_untrusted", "dark red", "default", "default", "#a22", "default"),
("list_focus_untrusted", "black", "dark gray", "standout", "#810", "#aaa"),
+ ("list_unresponsive", "yellow", "default", "default", "#b92", "default"),
+ ("list_focus_unresponsive", "black", "light gray", "standout", "#530", "#aaa"),
("topic_list_normal", "dark gray", "default", "default", "#222", "default"),
("browser_controls", "dark gray", "default", "default", "#444", "default"),
("progress_full", "black", "dark gray", "standout", "#111", "#bbb"),
diff --git a/nomadnet/ui/textui/Network.py b/nomadnet/ui/textui/Network.py
index 7de57eb..cbbf880 100644
--- a/nomadnet/ui/textui/Network.py
+++ b/nomadnet/ui/textui/Network.py
@@ -1576,7 +1576,11 @@ class LXMFPeers(urwid.WidgetWrap):
self.pile = urwid.Pile([urwid.Text(("warning_text", g["info"]+"\n"), align="center"), SelectText(("warning_text", "Currently, no LXMF nodes are peered\n\n"), align="center")])
self.display_widget = urwid.Filler(self.pile, valign="top", height="pack")
- urwid.WidgetWrap.__init__(self, urwid.AttrMap(urwid.LineBox(self.display_widget, title="LXMF Propagation Peers"), widget_style))
+ if hasattr(self, "peer_list") and self.peer_list:
+ pl = len(self.peer_list)
+ else:
+ pl = 0
+ urwid.WidgetWrap.__init__(self, urwid.AttrMap(urwid.LineBox(self.display_widget, title=f"LXMF Propagation Peers ({pl})"), widget_style))
def keypress(self, size, key):
if key == "up" and (self.no_content or self.ilb.first_item_is_selected()):
@@ -1611,13 +1615,13 @@ class LXMFPeers(urwid.WidgetWrap):
def make_peer_widgets(self):
widget_list = []
- for peer_id in self.peer_list:
+ sorted_peers = sorted(self.peer_list, key=lambda pid: self.peer_list[pid].link_establishment_rate, reverse=True)
+ for peer_id in sorted_peers:
peer = self.peer_list[peer_id]
pe = LXMFPeerEntry(self.app, peer, self)
pe.destination_hash = peer.destination_hash
widget_list.append(pe)
- # TODO: Sort list
return widget_list
class LXMFPeerEntry(urwid.WidgetWrap):
@@ -1633,7 +1637,7 @@ class LXMFPeerEntry(urwid.WidgetWrap):
node_hash = RNS.Destination.hash_from_name_and_identity("nomadnetwork.node", node_identity)
display_name = self.app.directory.alleged_display_str(node_hash)
if display_name != None:
- display_str += " "+str(display_name)
+ display_str = str(display_name)+"\n "+display_str
sym = g["sent"]
style = "list_unknown"
@@ -1643,8 +1647,12 @@ class LXMFPeerEntry(urwid.WidgetWrap):
if hasattr(peer, "alive"):
if peer.alive:
alive_string = "Available"
+ style = "list_normal"
+ focus_style = "list_focus"
else:
alive_string = "Unresponsive"
+ style = "list_unresponsive"
+ focus_style = "list_focus_unresponsive"
widget = ListEntry(sym+" "+display_str+"\n "+alive_string+", last heard "+pretty_date(int(peer.last_heard))+"\n "+str(len(peer.unhandled_messages))+" unhandled LXMs, "+RNS.prettysize(peer.link_establishment_rate/8, "b")+"/s LER")
# urwid.connect_signal(widget, "click", delegate.connect_node, node)
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────